import React from 'react'
import { Form, Input, Select, Button, Row, Col } from 'antd'
const FormItem = Form.Item
const { Option } = Select
const TopInquire = ({ form: { getFieldDecorator, getFieldsValue, resetFields }, onSearch, onClick, onClick4, workShopList, advanced }) => {
    const cz = () => {
        if (onClick) {
            onClick()
        }
    }
    const advancedss = () => {
        if (onClick4) {
            onClick4()
        }
    }
    const formItemLayout = {
        // 抽屉里面Form。二列的布局比例
        labelCol: {
            span: 6
        },
        wrapperCol: {
            span: 16
        },
    };
    return (
        <div>
            <Form>
                <Row gutter={24}>
                    <Col span={5}>
                        <FormItem label='批 号'{...formItemLayout}>
                            {
                                getFieldDecorator('batchNo', {
                                    getValueFromEvent: (event) => {
                                        return event.target.value.replace(/\s+/g, "")
                                    },
                                })(
                                    <Input placeholder='请输入' allowClear onPressEnter={() => onSearch(getFieldsValue())} maxLength={20}></Input>
                                )
                            }
                        </FormItem>
                    </Col>
                    <Col span={5}>
                        <FormItem label='领料单号'{...formItemLayout}>
                            {
                                getFieldDecorator('acceptCode', {
                                    getValueFromEvent: (event) => {
                                        return event.target.value.replace(/\s+/g, "")
                                    },
                                })(
                                    <Input placeholder='请输入' allowClear onPressEnter={() => onSearch(getFieldsValue())} maxLength={20}></Input>
                                )
                            }
                        </FormItem>
                    </Col>
                    <Col span={5}>
                        <FormItem label='发料状态'{...formItemLayout}>
                            {
                                getFieldDecorator('partReceiveStatus', {
                                    // initialValue: '待确认'
                                })(
                                    <Select allowClear={true} placeholder='请选择发料状态'>
                                        <Option value={1}>待发布</Option>
                                        <Option value={2}>待确认</Option>
                                        <Option value={3}>未完成</Option>
                                        <Option value={4}>已完成</Option>
                                    </Select>
                                )
                            }
                        </FormItem>
                    </Col>
                    <Col span={5}>
                        <FormItem label='装配部门'{...formItemLayout}>
                            {
                                getFieldDecorator('locationCode', {
                                    // initialValue: '全部'
                                })(
                                    <Select allowClear={true} placeholder='请选择装配部门'>
                                        {
                                            workShopList && workShopList.map(item => <Option key={item.code} value={item.code}>{item.name}</Option>)
                                        }
                                    </Select>
                                )
                            }
                        </FormItem>
                    </Col>
                    <Col span={4} style={{ display: 'flex' }} className="serarch-btns">
                        <FormItem>
                            <Button type="primary" icon="search" onClick={() => onSearch(getFieldsValue())}>查询</Button>
                        </FormItem>
                        <FormItem>
                            <Button type='primary' icon={advanced ? 'up' : 'down'} onClick={() => advancedss()}>展开</Button>
                        </FormItem>
                        <FormItem>
                            <Button type="default" onClick={() => {
                                cz()
                                resetFields()
                            }}
                                icon={'redo'}
                            >重置</Button>
                        </FormItem>
                    </Col>
                </Row>
                <Row gutter={24}>
                    {
                        advanced ? <Col span={5}>
                            <FormItem label='物料编码'{...formItemLayout}>
                                {
                                    getFieldDecorator('partCode', {
                                        getValueFromEvent: (event) => {
                                            return event.target.value.replace(/\s+/g, "")
                                        },
                                    })(
                                        <Input placeholder='请输入' allowClear onPressEnter={() => onSearch(getFieldsValue())} maxLength={20}></Input>
                                    )
                                }
                            </FormItem>
                        </Col> : ''
                    }
                    {
                        advanced ? <Col span={5}>
                            <FormItem label='图 号'{...formItemLayout}>
                                {
                                    getFieldDecorator('paperCode', {
                                        getValueFromEvent: (event) => {
                                            return event.target.value.replace(/\s+/g, "")
                                        },
                                    })(
                                        <Input placeholder='请输入' allowClear onPressEnter={() => onSearch(getFieldsValue())} maxLength={20}></Input>
                                    )
                                }
                            </FormItem>
                        </Col> : ''
                    }
                    {
                        advanced ? <Col span={5}>
                            <FormItem label='物料名称'{...formItemLayout}>
                                {
                                    getFieldDecorator('partName', {
                                        getValueFromEvent: (event) => {
                                            return event.target.value.replace(/\s+/g, "")
                                        },
                                    })(
                                        <Input allowClear placeholder='请输入' onPressEnter={() => onSearch(getFieldsValue())} maxLength={20} ></Input>
                                    )
                                }
                            </FormItem>
                        </Col> : ''
                    }
                    {
                        advanced ? <Col span={5}>
                            <FormItem label='物料变更'{...formItemLayout}>
                                {
                                    getFieldDecorator('partChangeAttitude', {
                                        // initialValue: '全部'
                                    })(
                                        <Select allowClear={true} placeholder='请选择物料变更'>
                                            <Option value={1}>新增</Option>
                                            <Option value={2}>取消</Option>
                                            <Option value={3}>属性变化</Option>
                                            <Option value={4}>回仓</Option>
                                        </Select>
                                    )
                                }
                            </FormItem>
                        </Col> : ''
                    }
                </Row>
                <Row gutter={24}>
                </Row>
            </Form>
        </div>
    )
}
export default Form.create()(TopInquire)
